package com.zyong.design.pattern.memento.case1;

/**
 * @program: zyong-design-pattern
 * @ClassName: Client
 * @author: zyong
 * @create: 2024-05-11 23:49
 */
public class Client {
    public static void main(String[] args) {
        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();

        originator.setState("状态#1 攻击力100");
        caretaker.add(originator.saveStateToMemento());

        originator.setState("状态#2 攻击力80");
        caretaker.add(originator.saveStateToMemento());

        originator.setState("状态#3 攻击力50");
        caretaker.add(originator.saveStateToMemento());

        System.out.println("当前状态是:" + originator.getState());


        // 希望得到状态1，将originator的状态恢复到状态1
        originator.getStateFromMemento(caretaker.get(0));
        System.out.println("恢复到状态1，当前的状态是:" + originator.getState());

    }
}
